package org.yourscrum.web;

privileged aspect ProjectController_Roo_Controller {
    
    @org.springframework.web.bind.annotation.RequestMapping(value = "/project", method = org.springframework.web.bind.annotation.RequestMethod.POST)    
    public java.lang.String ProjectController.create(@org.springframework.web.bind.annotation.ModelAttribute("project") org.yourscrum.domain.Project project, org.springframework.validation.BindingResult result) {    
        if (project == null) throw new IllegalArgumentException("A project is required");        
        for(javax.validation.ConstraintViolation<org.yourscrum.domain.Project> constraint : javax.validation.Validation.buildDefaultValidatorFactory().getValidator().validate(project)) {        
            result.rejectValue(constraint.getPropertyPath(), null, constraint.getMessage());            
        }        
        if (result.hasErrors()) {        
            return "project/create";            
        }        
        project.persist();        
        return "redirect:/project/" + project.getId();        
    }    
    
    @org.springframework.web.bind.annotation.RequestMapping(value = "/project/form", method = org.springframework.web.bind.annotation.RequestMethod.GET)    
    public java.lang.String ProjectController.createForm(org.springframework.ui.ModelMap modelMap) {    
        modelMap.addAttribute("project", new org.yourscrum.domain.Project());        
        modelMap.addAttribute("teams", org.yourscrum.domain.Team.findAllTeams());        
        modelMap.addAttribute("themes", org.yourscrum.domain.Theme.findAllThemes());        
        return "project/create";        
    }    
    
    @org.springframework.web.bind.annotation.RequestMapping(value = "/project/{id}", method = org.springframework.web.bind.annotation.RequestMethod.GET)    
    public java.lang.String ProjectController.show(@org.springframework.web.bind.annotation.PathVariable("id") Long id, org.springframework.ui.ModelMap modelMap) {    
        if (id == null) throw new IllegalArgumentException("An Identifier is required");        
        modelMap.addAttribute("project", org.yourscrum.domain.Project.findProject(id));        
        return "project/show";        
    }    
    
    @org.springframework.web.bind.annotation.RequestMapping(value = "/project", method = org.springframework.web.bind.annotation.RequestMethod.GET)    
    public java.lang.String ProjectController.list(org.springframework.ui.ModelMap modelMap) {    
        modelMap.addAttribute("projects", org.yourscrum.domain.Project.findAllProjects());        
        return "project/list";        
    }    
    
    @org.springframework.web.bind.annotation.RequestMapping(method = org.springframework.web.bind.annotation.RequestMethod.PUT)    
    public java.lang.String ProjectController.update(@org.springframework.web.bind.annotation.ModelAttribute("project") org.yourscrum.domain.Project project, org.springframework.validation.BindingResult result) {    
        if (project == null) throw new IllegalArgumentException("A project is required");        
        for(javax.validation.ConstraintViolation<org.yourscrum.domain.Project> constraint : javax.validation.Validation.buildDefaultValidatorFactory().getValidator().validate(project)) {        
            result.rejectValue(constraint.getPropertyPath(), null, constraint.getMessage());            
        }        
        if (result.hasErrors()) {        
            return "project/update";            
        }        
        project.merge();        
        return "redirect:/project/" + project.getId();        
    }    
    
    @org.springframework.web.bind.annotation.RequestMapping(value = "/project/{id}/form", method = org.springframework.web.bind.annotation.RequestMethod.GET)    
    public java.lang.String ProjectController.updateForm(@org.springframework.web.bind.annotation.PathVariable("id") java.lang.Long id, org.springframework.ui.ModelMap modelMap) {    
        if (id == null) throw new IllegalArgumentException("An Identifier is required");        
        modelMap.addAttribute("project", org.yourscrum.domain.Project.findProject(id));        
        modelMap.addAttribute("teams", org.yourscrum.domain.Team.findAllTeams());        
        modelMap.addAttribute("themes", org.yourscrum.domain.Theme.findAllThemes());        
        return "project/update";        
    }    
    
    @org.springframework.web.bind.annotation.RequestMapping(value = "/project/{id}", method = org.springframework.web.bind.annotation.RequestMethod.DELETE)    
    public java.lang.String ProjectController.delete(@org.springframework.web.bind.annotation.PathVariable("id") java.lang.Long id) {    
        if (id == null) throw new IllegalArgumentException("An Identifier is required");        
        org.yourscrum.domain.Project.findProject(id).remove();        
        return "redirect:/project";        
    }    
    
}
